//
//  MainViewController.m
//  FangXinLang
//
//  Created by AJY on 16/9/18.
//  Copyright © 2016年 AJY. All rights reserved.
//

#import "MainViewController.h"
#import "HomeViewController.h"
#import "FindViewController.h"
#import "HotViewController.h"
#import "MeViewController.h"
#import "NavigationController.h"


@interface MainViewController ()

@end

@implementation MainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
                    //***首页***//
    HomeViewController *home=[[HomeViewController alloc]init];
    [self addchildcontroller:home andTitle:@"首页" andimag:@"feed_tab_ico_1_normal" andseletedImage:@"feed_tab_ico_1_enabled"];
                    //***热门***//
    HotViewController *hot=[[HotViewController alloc]init];
    [self addchildcontroller:hot andTitle:@"热门" andimag:@"feed_tab_ico_2_normal" andseletedImage:@"feed_tab_ico_2_enabled"];
                    //***发现***//
    FindViewController *find=[[FindViewController alloc]init];
    [self  addchildcontroller:find andTitle:@"发现" andimag:@"feed_tab_ico_3_normal"andseletedImage:@"feed_tab_ico_3_enabled"];
                    //***我的***//
    MeViewController *me=[[MeViewController alloc]init];
    [self addchildcontroller:me andTitle:@"我的" andimag:@"feed_tab_ico_4_normal" andseletedImage:@"feed_tab_ico_4_enabled"];
}
-(void)addchildcontroller:(UIViewController *)viewcontroller andTitle:(NSString *)title andimag:(NSString *)image andseletedImage:(NSString *)seletedimage{
    NavigationController * na = [[NavigationController alloc]initWithRootViewController:viewcontroller];
    [self addChildViewController:na];
    
    na.tabBarItem.title=title;
    //设置文本属性（可以设置文字的颜色 大小  最好设置成可变的字典）字体大小只能在默认状态下设置（没有选中状态下）
    NSMutableDictionary *dic=[NSMutableDictionary dictionary];
    dic[NSForegroundColorAttributeName]=[UIColor redColor];
    [na.tabBarItem setTitleTextAttributes:dic forState:UIControlStateSelected];
    //渲染图片
    UIImage *im=[UIImage imageNamed:image];
    im=[im imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    na.tabBarItem.image=im;
    //选中的图片
    UIImage *img=[UIImage imageNamed:seletedimage];
    img=[img imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    na.tabBarItem.selectedImage=img;
}


@end
